package losrebellos.lospistoleros.core.view.events 
{
	import losrebellos.lospistoleros.core.controller.events.IPControllerEventDispatcher;
	import losrebellos.lospistoleros.core.controller.events.PControllerEventDispatcher;
	import losrebellos.lospistoleros.core.model.events.IPModelEventDispatcher;
	import losrebellos.lospistoleros.core.model.events.PModelEventDispatcher;
	import losrebellos.lospistoleros.core.registered.events.PRegisteredEventDispatcher;
	import losrebellos.lospistoleros.core.registration.PRegistrationManager;

	/*
	 *
	 * @author los rebellos - ben@benoitvinay.com
	 *
	 */
	public class PEventDispatcher extends PRegisteredEventDispatcher implements IPViewEventDispatcher
	{
		/*
		 * 
		 * VARIABLES
		 * 
		 */
		protected var _model:IPModelEventDispatcher;
		protected var _controller:IPControllerEventDispatcher;
		
		
		/*
		 *
		 * CONSTRUCTOR
		 *
		 */
		public function PEventDispatcher(name:String = null, type:String = null)
		{
			super(name, type);
			
			_model = createModel();
			_controller = createController();
			
			PRegistrationManager.instance.registerView(this);
		}
		
		
		/*
		 * 
		 * CREATION
		 * 
		 */
		protected function createModel():IPModelEventDispatcher
		{
			return new PModelEventDispatcher();
		}
		protected function createController():IPControllerEventDispatcher
		{
			return new PControllerEventDispatcher(_model, this);
		}

		
		/*
		 * 
		 * MVC
		 * 
		 */
		public function setModel(m:IPModelEventDispatcher):void
		{
			_model = m;
		}
		public function getModel():IPModelEventDispatcher
		{
			return _model;
		}
		public function setController(c:IPControllerEventDispatcher):void
		{
			_controller = c;
		}
		public function getController():IPControllerEventDispatcher
		{
			return _controller;
		}
		
		
		/*
		 * 
		 * INTERACTIVITY
		 * 
		 */
		public function initialize():void
		{
			
		}
		public function finalize():void
		{
			
		}
		public function update():void
		{
			
		}
		
		
		/*
		 * 
		 * EVENTS
		 * 
		 */
		protected function addEvents():void
		{
			
		}
		protected function removeEvents():void
		{
			
		}
	}
}